package edu.mit.compilers.assembly.x64.codes;

import edu.mit.compilers.assembly.x64.basic.X64Operand;

public class X64IncrementCode extends X64Code {
    public enum Type {
        INC,
        DEC,
    }

    private final X64Operand src;   // also dest
    private final Type type;

    public X64IncrementCode(X64Operand src, Type type) {
        this.src = src;
        this.type = type;
    }

    @Override
    protected String getStringFroShow(String prefix, boolean debug) {
        return prefix + typeToInstruction(type) + TAB + src.getAddress() + '\n';
    }

    private String typeToInstruction(Type type) {
        return type == Type.INC ? "incq" : "decq";
    }
}
